package org.jradweb.tools.generator.freemarker.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

import freemarker.cache.TemplateLoader;
/**
 * Default template loader, load from 'freemarker/' in class path 
 *
 * Created On 2008-2-29
 * @author <a href="mailto:wagzhi@gmail.com">Paul Wang</a>
 * @version $Id: DefaultTemplateLoader.java 148 2008-10-10 03:07:23Z wagzhi $
 */
public class DefaultTemplateLoader implements TemplateLoader {

	public void closeTemplateSource(Object arg0) throws IOException {
		
	}

	public Object findTemplateSource(String name) throws IOException {
		return name;
	}

	public long getLastModified(Object arg0) {
		return -1;
	}

	public Reader getReader(Object name, String encoding) throws IOException {
		InputStream is=ResourceLoader.loadResource("freemarker/"+name);	
		return new InputStreamReader(is);
	}

}
